package com.sunxiansheng.user.event;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * Description: 发布事件
 * @Author sun
 * @Create 2024/7/24 14:32
 * @Version 1.0
 */
@Service
@Slf4j
public class PersonEventPublisher {

    @Resource
    private ApplicationEventPublisher applicationEventPublisher;

    /**
     * 当创建Person对象时发布事件
     * @param person
     */
    public void createPerson(Person person) {
       applicationEventPublisher.publishEvent(new PersonChangeEvent(person, "create"));
    }

    // 其他情况，发布事件

}